A microcontroller, such as those in the various versions of the 8051 family of microcontrollers, includes a microprocessor, code memory, peripherals, and port registers mounted on a single chip. The microprocessor includes an arithmetic/logic unit, SRAM/register files, an address controller, a program counter, etc.
To find various run-time errors in a microcontroller application that includes a microcontroller and other associated hardware, a debugger system is used. A debugger program runs on a Host computer and executes a host program for the purpose of finding run-time errors. Such errors are often not apparent until a debug program is either actually executed in a Target microcontroller system or is executed in a simulator for the Target microcontroller system. A debugger system provides various diagnostic features such as executing the program until a certain address (a breakpoint) is reached, single-stepping through instructions while displaying the contents of CPU registers, status bits, or input/output ports.
Various debugging techniques have used interfaces that require a number of interconnect wires, such as 6-wire and 8-wire interfaces that use scarce pins on a low-cost microcontroller. Often the Host computer that provides a debugging program must be specially programmed to provide appropriate drivers for the microcontroller. Tying up several pins of a low-cost microcontroller along with the design time for providing suitable interfacing between the Host computer and the microcontroller are significant obstacles to successfully debugging various microcomputer applications.
Note that some debug approaches for microcontrollers make an expanded, special chip version of a Target microcontroller chip to facilitate debugging. The expanded chip version has extra pins that are used to interface with an extra parallel or serial channel that provides an additional port through which extra information is input/output to/from the register file of the Target microcontroller. These extra pins are connected to some sort of debug master or to the Host computer with the same parallel or serial interface. The expanded portion of the special chip version of a Target microcontroller chip can be as big as the regular part of the Target microcontroller chip in case of a parallel expansion interface. Producing a standard chip and an expanded chip requires two different mask sets. For a low-cost, high volume microcontroller, such as a 8051 type, the expanded chip is expensive and impractical because of the low cost nature of the standard 8051 chip, while the expanded, special version would be a low volume, expensive chip. Again, emulating the special chip would require another expanded chip of the expanded chip. As a consequence, a 20 pin part is emulated by a 40 pin part, etc.
A goal of debugging is to provide an alternate way for a debug program developer to have access to the internal resources of a microprocessor of the microcontroller. Access is needed to the register file and the program counter of the microprocessor, which are internal elements and are not usually available at the ports of the microcontroller. In an 8051 type of microcontroller, I/O ports are special registers that have to attend to their own tasks in a target application environment. These I/O ports receive signals from the application operating environment, but the debug program developer may also want to use these same ports. It is desirable that the register file and the peripheral register be accessible even when all of the ports are used for communication with the environment of the application being debugged.